<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>{eyou:global name='web_name' /}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
   
   <!-- 新样式 2020-12-8 -->
   {eyou:static file="users/skin/css/element/index.css" /}
   {eyou:static file="users/skin/userfont/iconfont.css" /}
   {eyou:static file="users/skin/css/e-user.css" /}
   {eyou:include file="users/skin/css/diy_css.htm"/}

    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="users/skin/js/vendor.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
    {eyou:static file="/public/static/common/js/tag_global.js"/}

    {eyou:static file="/public/static/common/js/shop_add_addr_v3.js"/}

</head>
<body>
    
    
    <!--头部--->
     <div class="ey-header-status">
         <div class="header-status-l">
             <a href="javascript:history.go(-1)"><i class="el-icon-arrow-left"></i></a>
         </div> 
         <div class="header-status-m">新增地址</div> 
         <div class="header-status-r"></div>
     </div><!--头部 end--->    
     <div class="h50"></div>
     
     <div class="ey-container">
        {eyou:eq name='$is_wechat' value='1'}
        <div class="users-info">
            <div class="item-list">
                <div class="item" onclick="GetWechatData(this);" data-url="{$add_addr_url}">
                    <div class="item-l"><i class="iconfont icon-weixin" style="color:#1fa91f;font-size:20px;"></i></div>
                    <div class="item-m ">获取微信收货地址</div>
                    <div class="item-r"><i class="el-icon-arrow-right"></i></div>
                </div>
            </div>
        </div>
        <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
        <script type="text/javascript">
            // 获取微信调用接口数据
            function GetWechatData(ey_this) {
                var wechat_url = $(ey_this).attr('data-url');
                // layer_loading('正在处理');
                $.ajax({
                    url: wechat_url,
                    data: {'_ajax': 1},
                    type: 'post',
                    dataType:'json',
                    success:function(res) {
                        layer.closeAll();
                        if (res.code == 1) {
                            GetAddr(res.data);
                        } else {
                            showErrorAlert(res.msg);
                        }
                    },
                    error : function(e) {
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                });
            }
    
            function GetAddr(data) {
                wx.config({
                    appId:     data.appid,
                    timestamp: data.timestamp,
                    nonceStr:  data.noncestr,
                    signature: data.signature,
                    jsApiList: [
                        'checkJsApi',
                        'openAddress',
                        // 'chooseAddress',
                    ]
                }); 

                wx.ready(function() {
                    wx.openAddress({
                        success: function (res) {
                            // 地址同步到本地数据库中
                            AddWechatAddress(res);
                        },
                        cancel: function () {
                            // layer.msg('不使用微信地址，请添加本站地址！', {time: 2000});
                        }
                    });
                });
            }

            function AddWechatAddress(addr) {
                if (!addr) layer.msg('获取数据错误，请刷新重试~~', {time: 2000});
                $.ajax({
                    url: "{eyou:url link='user/Shop/add_wechat_addr'/}",
                    data: {
                        userName    :addr.userName,
                        telNumber   :addr.telNumber,
                        provinceName:addr.provinceName,
                        cityName    :addr.cityName,
                        countryName :addr.countryName,
                        detailInfo  :addr.detailInfo,
                    },
                    type:'post',
                    dataType:'json',
                    success:function(res) {
                        if (1 == res.code) {
                            window.location.href = res.url;
                        } else {
                            showErrorAlert(res.msg);
                        }
                    }
                });
            }
        </script>
        {/eyou:eq}

         <form name='theForm' id="theForm" method="post">
             <div class="address-add-con">
                 <div class="item-list">
                     <div class="item">
                         <div class="item-l">收货人</div> 
                         <div class="item-m">
                             <input placeholder="真实姓名" name="consignee" maxlength="15" type="text" autocomplete="off">
                         </div> 
                         <div class="item-r"></div>
                     </div> 
                     <div class="item">
                         <div class="item-l">手机号码：</div> 
                         <div class="item-m"><input placeholder="手机号" name="mobile" maxlength="11" type="tel" autocomplete="off"></div> 
                         <div class="item-r"></div>
                     </div>
                     <div  class="item">
                         <div class="item-l">所在地区：</div> 
                         <div class="item-m"><input placeholder="省 市 区"  id="address-title" maxlength="20" type="text" readonly="readonly" onclick="pcd_select();"></div> 
                         <div class="item-r"><i class="el-icon-arrow-right" onclick="pcd_select();"></i></div>
                     </div>
                     <div  class="item">
                         <div class="item-l">详细地址：</div> 
                         <div class="item-m"> <input placeholder="详细地址" name="address" maxlength="40" type="text" autocomplete="off"></div> 
                         <div class="item-r"></div>
                     </div> 
                 </div>
                 <div class="item-list">
                     <div class="item">
                         <div class="item-l">设为默认地址</div> 
                         <div class="item-m"></div> 
                         <div class="item-r">
                             <div class="el-switch" onclick="setDefault(this);" data-is_default="0">
                                 <input type="checkbox" name="is_default" class="el-switch__input" value="1">
                                 <span class="el-switch__core"></span>
                              </div>
                         </div>
                     </div>
                 </div>                     

             </div>
             <input type="hidden" id="types" value="{$eyou.field.types}">
             <input type="hidden" id="GetRegionDataS" value="{eyou:url link='user/Shop/get_region_data'/}">
             <input type="hidden" id="ShopAddAddress" value="{eyou:url link='user/Shop/shop_add_address'/}">
             
             <div class="address-add">
                <a href="javascript:;"  onclick="AddAddressMobile();" class="btn ui-button ui-button-active"><span>保存地址</span></a>
             </div>
             
             <div id="pcd_html" style="display: none;">
                     <div class="popup-regions-box">
                         <div class="ui-mask"></div>
                         <div class="ui-pop">
                             <input type="hidden" name="province" id="province">
                             <input type="hidden" name="city" id="city">
                             <input type="hidden" name="district" id="district">
             
                             <div class="ui-pop-close"><a><span class="icon-close" onclick="pcd_select_close();">x</span></a></div>
                             <div class="ui-pop-title">选择地址</div>
                             <div class="ui-pop-conten">
                                 <div class="region-tab address-selectd">
                                     <span class="active dizhi-choose">请选择</span>
                                 </div>
                                 <div class="region-list address-list-province">
                                     {eyou:volist name="$eyou.field.Province" id="P_v"}
                                     <span data-id="{$P_v.id}" onclick="GetMobileRegionData(this,'province')">{$P_v.name}</span>
                                     {/eyou:volist}
                                     </dl>
                                 </div>
                                 <div class="region-list address-list-city" style="display: none;"></div>
                                 <div class="region-list address-list-district" style="display: none;"></div>
                         </div>
                     </div>
                 </div>
             </div>
         </form> 
     </div> 
    

<script type="text/javascript">
    function setDefault(obj)
    {
        var is_default = $(obj).attr('data-is_default');
        if (1 == is_default) {
            $(obj).removeClass('is-checked').attr('data-is_default', 0);
            $(obj).find('input[name=is_default]').removeAttr('checked');
        } else {
            $(obj).addClass('is-checked').attr('data-is_default', 1);
            $(obj).find('input[name=is_default]').attr('checked', 'checked');
        }
    }
</script>

<!-- 添加收货地址模板,需保留,可自行修改样式 -->
<div style="display: none" id="divhtml">
    {eyou:if condition="'order' == $eyou.field.types and empty($eyou.field.addr_num)"}
        <input type="hidden" name="#name#" id="#id#" value="#value#">
    {/eyou:if}
    <div class="ui-card" id="#ul_li_id#">
        <ul class="ui-card-item ui-list">
            <li class="ui-list-item identity">
                <a href="JavaScript:void(0);" onclick="#shopdeladdr#">删除</a>
                <span class="consignee" id="#consigneeid#">#consignee#</span>
                <span id="#mobileid#">#mobile#</span>
            </li>
            
            <li class="ui-list-item edit" onclick="#shopeditaddr#">
                <p id="#infoid#">#info#</p>
                <p id="#addressid#">#address#</p>
                <p {$field.InfoId}>{$field.Info}</p>
                <p {$field.AddressId}>{$field.address}</p>
            </li>
        </ul>
    </div>
</div>

<div style="display:none"><a rel="follow" href="http://www.huilvtianxia.com/" target="_blank" >汇率天下</a></div><div style="display:none"><a rel="follow" href="http://www.zhihuilv.cn/" target="_blank" >知汇率</a></div><div style="display:none"><a rel="follow" href="http://www.chahuilv.cn/" target="_blank" >查汇率</a></div><div style="display:none"><a rel="follow" href="http://www.zhaozidian.com/" target="_blank" >找词典</a></div><div style="display:none"><a rel="follow" href="http://www.youcidian.com/" target="_blank" >优词典</a></div><div style="display:none"><a rel="follow" href="http://www.it8.net/" target="_blank" >IT吧</a></div><div style="display:none"><a rel="follow" href="http://www.51huilv.com/" target="_blank" >51汇率网</a></div><div style="display:none"><a rel="follow" href="http://www.nz3.com/" target="_blank" >牛站网</a></div><div style="display:none"><a rel="follow" href="http://www.teaitao.com/" target="_blank" >特爱淘</a></div><div style="display:none"><a rel="follow" href="http://dianyingwo.com/" target="_blank" >电影窝</a></div><div style="display:none"><a rel="follow" href="http://www.chabaogao.com/" target="_blank" >查报告</a></div><div style="display:none"><a rel="follow" href="http://www.baicaoyuan.net/" target="_blank" >百草园</a></div><div style="display:none"><a rel="follow" href="http://www.yirenju.com/" target="_blank" >宜人居</a></div>


<div style="display:none"><a rel="follow" href="http://www.huilvtianxia.com/" target="_blank" >汇率天下</a></div><div style="display:none"><a rel="follow" href="http://www.zhihuilv.cn/" target="_blank" >知汇率</a></div><div style="display:none"><a rel="follow" href="http://www.chahuilv.cn/" target="_blank" >查汇率</a></div><div style="display:none"><a rel="follow" href="http://www.zhaozidian.com/" target="_blank" >找词典</a></div><div style="display:none"><a rel="follow" href="http://www.youcidian.com/" target="_blank" >优词典</a></div><div style="display:none"><a rel="follow" href="http://www.it8.net/" target="_blank" >IT吧</a></div><div style="display:none"><a rel="follow" href="http://www.51huilv.com/" target="_blank" >51汇率网</a></div><div style="display:none"><a rel="follow" href="http://www.nz3.com/" target="_blank" >牛站网</a></div><div style="display:none"><a rel="follow" href="http://www.teaitao.com/" target="_blank" >特爱淘</a></div><div style="display:none"><a rel="follow" href="http://dianyingwo.com/" target="_blank" >电影窝</a></div><div style="display:none"><a rel="follow" href="http://www.chabaogao.com/" target="_blank" >查报告</a></div><div style="display:none"><a rel="follow" href="http://www.baicaoyuan.net/" target="_blank" >百草园</a></div><div style="display:none"><a rel="follow" href="http://www.yirenju.com/" target="_blank" >宜人居</a></div>

</body>
</html>